Run with Clamav - SquidClamav
2011/05/28 |
Install SquidClamav and Configure Proxy Server in order to scan download files to protect from virus.
Install Clamav first.
|
|
[1] | Install Clamd |
[root@lan ~]#
[root@lan ~]# yum -y install clamav-server cp /usr/share/doc/clamav-server-*/clamd.conf /etc/clamd.d/squid.conf
[root@lan ~]#
vi /etc/clamd.d/squid.conf # line 8: make it comment # Example
# line 14: uncomment and change LogFile /var/log/clamd.squid
# line 61: uncomment and change PidFile /var/run/clamd.squid/clamd.pid
# line 65: uncomment TemporaryDirectory /var/tmp # line 80: uncomment and change LocalSocket /var/run/clamd.squid/clamd.sock
# line 96: uncomment TCPSocket 3310 # line 190: change User squidclamav
useradd -d /var/tmp -s /sbin/nologin squidclamav useradd: warning: the home directory already exists. Not copying any file from skel directory into it. [root@lan ~]# mkdir /var/run/clamd.squid [root@lan ~]# chown squidclamav. /var/run/clamd.squid [root@lan ~]# cp /usr/share/doc/clamav-server-*/clamd.sysconfig /etc/sysconfig/clamd.squid
[root@lan ~]#
vi /etc/sysconfig/clamd.squid # line 1, 2: uncomment and change CLAMD_CONFIGFILE=/etc/clamd.d/ squid.conf CLAMD_SOCKET=/var/run/ clamd.squid /clamd.sock
[root@lan ~]#
vi /etc/tmpfiles.d/clamd.squid.conf # create new d /var/run/clamd.squid 0755 squidclamav squidclamav - cp /usr/share/doc/clamav-server-*/clamd.init /etc/rc.d/init.d/clamd.squid
[root@lan ~]#
vi /etc/rc.d/init.d/clamd.squid # line 6: change CLAMD_SERVICE= squid
chmod 755 /etc/rc.d/init.d/clamd.squid [root@lan ~]# touch /var/log/clamd.squid [root@lan ~]# chown squidclamav. /var/log/clamd.squid [root@lan ~]# chmod 600 /var/log/clamd.squid [root@lan ~]# /etc/rc.d/init.d/clamd.squid start Starting clamd.squid (via systemctl): Starting clamd.squid: [ OK ] [ OK ] [root@lan ~]# chkconfig --add clamd.squid [root@lan ~]# chkconfig clamd.squid on |
[2] | Install c-icap |
[root@lan ~]# wget http://ftp.jaist.ac.jp/pub/sourceforge/c/project/c-/c-icap/c-icap/0.1.x/c_icap-0.1.6.tar.gz [root@lan ~]# tar zxvf c_icap-0.1.6.tar.gz [root@lan ~]# cd c_icap-0.1.6 [root@lan c_icap-0.1.6]# ./configure [root@lan c_icap-0.1.6]# [root@lan c_icap-0.1.6]# make install [root@lan c_icap-0.1.6]# [root@lan ~]# cp /usr/local/etc/c-icap.conf /etc
[root@lan ~]#
vi /etc/c-icap.conf # line 140: change admin address ServerAdmin root@srv.world
# line 149: change to your server name ServerName lan.srv.world
# line 497: add Service squidclamav squidclamav.so
mkdir /var/run/c-icap
[root@lan ~]#
vi /etc/tmpfiles.d/c-icap.conf # create new d /var/run/c-icap 0755 root root -
[root@lan ~]#
vi /etc/rc.d/init.d/c-icap # create init script #!/bin/bash # c-icap: Start/Stop c-icap # chkconfig: - 70 30 # description: c-icap is an implementation of an ICAP server. # processname: c-icap # pidfile: /var/run/c-icap/c-icap.pid . /etc/rc.d/init.d/functions . /etc/sysconfig/network CONFIG_FILE=/etc/c-icap.conf PID_DIR=/var/run/c-icap RETVAL=0 start() { echo -n $"Starting c-icap: " daemon /usr/local/bin/c-icap -f $CONFIG_FILE RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/c-icap return $RETVAL } stop() { echo -n $"Stopping c-icap: " killproc c-icap rm -f /var/run/c-icap/c-icap.ctl RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f $PID_DIR/c-icap.pid /var/lock/subsys/c-icap return $RETVAL } case "$1" in start) start ;; stop) stop ;; status) status c-icap ;; restart) stop start ;; *) echo $"Usage: $0 {start|stop|status|restart}" exit 1 esac exit $? chmod 755 /etc/rc.d/init.d/c-icap |
[3] | Install SquidClamav ( Download latest version of it from the following link ) http://sourceforge.net/projects/squidclamav/files/squidclamav/ |
[root@lan ~]# wget http://ftp.jaist.ac.jp/pub/sourceforge/s/project/sq/squidclamav/squidclamav/6.2/squidclamav-6.2.tar.gz [root@lan ~]# tar zxvf squidclamav-6.2.tar.gz [root@lan ~]# cd squidclamav-6.2 [root@lan squidclamav-6.2]# ./configure [root@lan squidclamav-6.2]# [root@lan squidclamav-6.2]# make install [root@lan squidclamav-6.2]#
[root@lan ~]#
vi /etc/squidclamav.conf # line 17: change( destination URL for redirect. Create it first ) redirect http://www.srv.world/error.html
# line 25: change( same with clamd ) clamd_local /var/run/clamd.squid/clamd.sock
/etc/rc.d/init.d/c-icap start Starting c-icap (via systemctl): Starting c-icap: [ OK ] [ OK ] [root@lan ~]# chkconfig --add /etc/rc.d/init.d/c-icap [root@lan ~]# chkconfig c-icap on |
[4] | Configure Squid |
[root@lan ~]#
vi /etc/squid/squid.conf # add at the last line
icap_enable on
icap_send_client_ip on icap_send_client_username on icap_client_username_header X-Authenticated-User icap_service service_req reqmod_precache bypass=1 icap://127.0.0.1:1344/squidclamav adaptation_access service_req allow all icap_service service_resp respmod_precache bypass=1 icap://127.0.0.1:1344/squidclamav adaptation_access service_resp allow all /etc/rc.d/init.d/squid restart Restarting squid (via systemctl): Stopping squid: ................[ OK ] Starting squid: .[ OK ] [ OK ] |
[5] | Try to access to a page that has trial virus from here. http://www.eicar.org/anti_virus_test_file.htm Click 'eicar.com' and rty to download it. Then, the error page that is set in the config of squidclamav. Virus is blocked normally. |